<?php
// +----------------------------------------------------------------------
// | INPHP
// | Copyright (c) https://inphp.cc All rights reserved.
// | 该文件源码由INPHP官方提供，使用协议以INPHP官方公告为准。
// +----------------------------------------------------------------------
// | 焦点图
// +----------------------------------------------------------------------
namespace app\cms\model;

use Inphp\Core\Db\PDO\Model;

class FocusModel extends Model
{
    protected string $tableName = "cms_focus";

    /**
     * 将图片数据输出为数组
     * @param string|null $data
     * @return array
     */
    public static function decodePictures(?string $data): array
    {
        if (empty($data)) {
            return [];
        }
        //
        $list = @json_decode($data, true) ?? [];
        foreach ($list as &$item) {
            $item["picture"] = attachmentUrl($item["picture"]);
        }
        return $list;
    }
}